﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace VMuktiAPI.GetIPAddress
{
    public static class ClsGetIP4Address
    {
        public static string GetIP4Address()
        {
            string IP4Address = String.Empty;
            try
            {
                foreach (IPAddress IPA in Dns.GetHostAddresses(System.Net.Dns.GetHostName()))
                {
                    if (IPA.AddressFamily.ToString() == "InterNetwork")
                    {
                        IP4Address = IPA.ToString();
                        break;
                    }
                }
                return IP4Address;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "GetIP4Address--:--ClsGetIP4Address.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);
                return IP4Address;

            }
        }

    }
}
